package com.fdb.efp.nls.service.dao;

import com.fdb.efp.nls.service.domain.AccLoanRevSub;
import com.fdb.efp.nls.service.vo.AccLoanRevSubVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>DAO interface:自助循环贷款台帐子表				<p>
 * @author chenqm1
 * @date 2018-05-12
 */
public interface AccLoanRevSubDao {
	
	public int insertAccLoanRevSub(AccLoanRevSub accLoanRevSub);
	
	public int deleteByPk(AccLoanRevSub accLoanRevSub);
	
	public int updateByPk(AccLoanRevSub accLoanRevSub);
	
	public AccLoanRevSub queryByPk(AccLoanRevSub accLoanRevSub);
	
	public List<AccLoanRevSub> queryAllOwnerByPage(AccLoanRevSubVO accLoanRevSub);
	
	public List<AccLoanRevSub> queryAllCurrOrgByPage(AccLoanRevSubVO accLoanRevSub);
	
	public List<AccLoanRevSub> queryAllCurrDownOrgByPage(AccLoanRevSubVO accLoanRevSub);
	
	public List<AccLoanRevSub> queryByBillNo(AccLoanRevSub accLoanRevSub);
	
	public int updateByBillNo(AccLoanRevSub accLoanRevSub);

	/**
	 * 分批查询子台账信息
	 * @param start 数据开始
	 * @param end 数据结束
	 * @return List<AccLoanRevSub>
	 */
	public List<AccLoanRevSub> queryAllAccLoanSub(int start, int end);
	//查询表中的条数
	public Integer queryTotalCount(AccLoanRevSub accLoanRevSub);

	//查询集合数据
	public List<AccLoanRevSub> queryListByAcctDateAndLimit(Map<String, Object> map);
	
	//贷款台账子表客户移交
	public int loanRevAppCusHandOver(@Param("fromUser") String fromUser, @Param("toUser") String toUser, @Param("fromBrId") String fromBrId, @Param("toBrId") String toBrId, @Param("cusIds") List<String> cusIds);
	//批量插入贷款子台账
	public int insertBatchAccLoanRevSub(@Param("accLoanRevSub") List<AccLoanRevSub> accLoanRevSubList);
	
	/**
	 * 借据余额为0时，将所有子台账结清
	 * @param accLoanRevSub
	 * @return
	 */
	public int updateStatusSettleByBillNo(AccLoanRevSub accLoanRevSub);
	
	/**
	 * 根据借据号更新子借据信息
	 * @param accLoanRevSub
	 * @return
	 */
	public int updateAccLoanRevSubByBillNo(AccLoanRevSub accLoanRevSub);

	/**
	 * 根据借据号和核心流水号查询是否已存在数据
	 * @param billNo
	 * @param coreSerno
	 * @return
	 */
	public int queryCountByBillNoAndCoreSerno(@Param("billNo") String billNo, @Param("coreSerno") String coreSerno);
	
	/**
	 * 根据贷款账号和核心流水号查询子台账
	 * @param loanAccount 贷款账号
	 * @param coreSerno 核心交易流水
	 * @return
	 */
	public AccLoanRevSub queryByLoanAccountAndCoreSerno(@Param("loanAccount") String loanAccount, @Param("coreSerno") String coreSerno);
}
